if (shell_js)
{
+ int i, j;
search_path = g_strsplit (shell_js, ":", -1);
+
+ /* The naive g_strsplit above will split 'resource:///foo/bar' into 'resource',
+ * '///foo/bar'. Combine these back together by looking for a literal 'resource'
+ * in the array. */
+ for (i = 0, j = 0; search_path[i];)
+ {
+ char *out;
+
+ if (strcmp (search_path[i], "resource") == 0 && search_path[i + 1] != NULL)
+ {
+ out = g_strconcat (search_path[i], ":", search_path[i + 1], NULL);
+ g_free (search_path[i]);
+ g_free (search_path[i + 1]);
+ i += 2;
+ }
+ else
+ {
+ out = search_path[i];
+ i += 1;
+ }
+
+ search_path[j++] = out;
+ }
+
+ search_path[j] = NULL; /* NULL-terminate the now possibly shorter array */
}
else
{